//
// Created by webturing on 2024/1/1.
//
#include<bits/stdc++.h>

using namespace std;
int g[100][100];
int n, m; //n点的个数 m边的个数
int book[100];
int tot = 0;
int q[100 * 100], head = 0, tail = -1;

void bfs(int k) {
    head = 0, tail = -1;
    q[++tail] = k;
    book[k] = 1;

    while (head <= tail) {

        int h = q[head++];
        cout << h << " ";
        for (int i = 0; i < n; i++) {
            if (book[i] == 0 && g[h][i] == 1) {
                q[++tail] = i;
                book[i] = 1;
            }
        }
    }

}

int main() {
    cin >> n;
    for (int x = 0; x < n; x++)
        for (int y = 0; y < n; y++) {
            cin >> g[x][y];
            m += g[x][y];
        }
    fill(book, book + n, 0);
    bfs(0);
    return 0;
}

